package zombiedefense.effects;

import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.geom.Point2D;
import zombiedefense.util.MathEx;
import zombiedefense.map.TileMap;

public class GunFlash extends Effect{
        
	private Image i;
        double rotation;
        Point2D.Double barrel;
	
	public void setFields(double x,double y,long effectTime, Image i, double rotation, Point2D.Double barrel){
	    super.setFields(x,y,effectTime);
	    
	    this.i = i;
	    this.rotation = rotation;
	    this.barrel = barrel;
	}
        
        public void update(long elapsedTime){
            if(player.getPlayer().isExpired()){
                expired = true;
                return;
	    }
	    
	    x = barrel.x;
            y = barrel.y;
            
            super.update(elapsedTime);
        }
        
        public void draw(Graphics2D g,int drawx,int drawy,TileMap map){    
            MathEx.drawRotatedImage(g,i, player.getPlayer().getRotation() + Math.toRadians(90),map.getScreenX(barrel.x - TileMap.pixelsToGridUnits(i.getWidth(null)/2)),
                    map.getScreenY(barrel.y - TileMap.pixelsToGridUnits(i.getHeight(null))),
                    map.getScreenX(barrel.x),map.getScreenY(barrel.y)); 
        }
	
	public int getHeight(){
	    return i.getHeight(null);
	}
	
	public int getWidth(){
	    return i.getWidth(null);
	}
    }
    